package com.gxuwz.leave.service;

import com.gxuwz.leave.dao.ClassDao;
import com.gxuwz.leave.dao.CourseDao;
import com.gxuwz.leave.entity.Class;
import com.gxuwz.leave.entity.Course;

import java.util.List;

public class CourseServiceImpl implements CourseService{
    private CourseDao courseDao;
    @Override
    public void addCourse(Course entity) {
        courseDao.insert(entity);
    }

    @Override
    public Course findCourse(String courseID) {
        Course course = new Course();
        course.setCourseID(courseID);
        List<Course> courseList = courseDao.query(course);
        if(courseList!=null){
            course = courseList.get(0);
        }
        return course;
    }

    @Override
    public void deleteCourse(String courseID) {
        courseDao.delete(courseID);
    }

    @Override
    public List<Course> list(Course entity) {
        return courseDao.query(entity);
    }

    @Override
    public void editCourse(Course entity) {
        courseDao.update(entity);
    }

    public void setCourseDao(CourseDao courseDao) {
        this.courseDao = courseDao;
    }
}
